﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xrm.Solutions.FrameworkSample.Common;

namespace Xrm.Solutions.FrameworkSample.UnitTests
{
    [TestClass]
    public class TestCreditLimitStub
    {
        [TestMethod]
        public void TestCreditLimitUsingStub()
        {
            IIdentityCheckService identityService
                = new Xrm.Solutions.FrameworkSample.Common.Fakes.StubIIdentityCheckService()
                {
                    RunCheckStringStringDateTimeString = (firstname, lastname, dob, address) =>
                    {
                        if (firstname == "Wael")
                            return 99;
                        else
                            return 60;
                    }
                };

            CreditLimitServiceDI creditLimitService = new CreditLimitServiceDI(identityService);

            int creditLimit = creditLimitService.IncreaseLimit("Wael",
                                        "Hamze",
                                        new DateTime(1990, 01, 01),
                                        "10 South Colonnade",
                                        500,
                                        600);

            Assert.AreEqual(creditLimit, 600);
        }
    }
}
